package com.bwjf.dzfp.action.user;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.bwjf.dzfp.biz.UserBiz;
import com.bwjf.dzfp.common.base.action.BaseAction;
import com.bwjf.dzfp.common.util.MD5;
import com.bwjf.dzfp.entity.User;

/**
 * 用户管理模块
 * @author ccy
 *
 */
@Controller
public class WxClientAction extends BaseAction {

	@Autowired
	public UserBiz userBiz;

	/**
	 * 登录
	 * 
	 * @param request
	 * @param response
	 * @param wxClientInfo
	 */
	@RequestMapping("/wxClient/login")
	public void login(HttpServletRequest request,
			HttpServletResponse response,String ss) {
		String userCode = request.getParameter("code") == null ? "" : request.getParameter("code");//帐号
		String pwd = request.getParameter("pwd") == null ? "" : request.getParameter("pwd");//密码
		
		User user = new User();
		user.setName(userCode);
		MD5 md5 = new MD5();
		String pwd2 = md5.getMD5ofStr(pwd);
		user.setPassword(pwd2);
		user = userBiz.getUser(user);
		if(null == user){
			
			getWriter(response).print("fail");
		}else{
			request.getSession().setAttribute("User", user);
			getWriter(response).print("success");
		}
	}

	
}
